<template>
  <div>
<!--  最上面的标题-->
  <div style="margin-top: 20px ">
    <van-nav-bar
        left-text="返回"
        right-text="提交"
        left-arrow
        @click-left="onClickLeft()"
        @click-right="onClickRight()"/>
  </div>
<!--  输入文本框-->
  <div>
      <van-field
          class="wb"
          v-model="user.content"
          maxlength="500"
          type="textarea"
          placeholder="这一刻的想法..."
      />
  </div>
  <div>
    <van-uploader v-model="fileList" class="tp">
      <template #preview-cover="{ file }">
        <div class="preview-cover van-ellipsis">{{ file.name }}</div>
      </template>
    </van-uploader>
  </div>
  </div>
</template>

<script>
export default {
  name: "PublishView",
  data(){
    return{
      user:{
        content:''
      }

    }
  },
  methods: {
    onClickLeft() {
      this.$router.push("/community")
    },
    onClickRight() {
      //目前没有跳转的！
        if (this.user.content!=''){
          this.axios.post("/api/circle/add.do",this.user).then((r)=>{
            if (r.data.code==200){
              //添加成功的
              this.$toast("发布成功")
              this.$router.push("/community")
            }else {
              this.$toast(r.data.msg)
            }
          });
        }else {
          this.$toast("请输入内容！！！")
        }
    }

  }

}
</script>

<style scoped>
.wb {
  height: 200px;
}

.tp {
  float: left;
  margin: 0 0 0 20px;
}

.preview-cover {
  position: absolute;
  bottom: 0;
  box-sizing: border-box;
  width: 100%;
  padding: 4px;
  color: #fff;
  font-size: 12px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
}

</style>
